Skip to content

feat: eventarc function support #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 19, 2023
Merged

feat: eventarc function support #61

merged 3 commits into from
Apr 19, 2023

Conversation

Salakar
Copy link
Member

@Salakar Salakar commented Apr 17, 2023

Testing

Deployed the following example:

from firebase_functions import eventarc_fn

@eventarc_fn.on_custom_event_published(
    event_type="firebase.extensions.storage-resize-images.v1.complete")
def onimageresize(event: eventarc_fn.CloudEvent) -> None:
    """
    Handle image resize events from the Firebase Storage Resize Images extension.
    https://extensions.dev/extensions/firebase/storage-resize-images
    """
    print("Received image resize completed event", event)

Deployment successful:

=== Deploying to 'python-functions-testing'...

i  deploying functions
i  functions: preparing codebase default for deployment
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged /Users/mike/development/projects/firebase-functions-python/samples/basic_eventarc/functions (1.55 KB) for uploading
i  functions: ensuring required API eventarcpublishing.googleapis.com is enabled...
✔  functions: required API eventarcpublishing.googleapis.com is enabled
i  functions: ensuring required API run.googleapis.com is enabled...
i  functions: ensuring required API eventarc.googleapis.com is enabled...
i  functions: ensuring required API pubsub.googleapis.com is enabled...
i  functions: ensuring required API storage.googleapis.com is enabled...
✔  functions: required API run.googleapis.com is enabled
✔  functions: required API eventarc.googleapis.com is enabled
✔  functions: required API pubsub.googleapis.com is enabled
✔  functions: required API storage.googleapis.com is enabled
i  functions: generating the service identity for pubsub.googleapis.com...
i  functions: generating the service identity for eventarc.googleapis.com...
✔  functions: functions folder uploaded successfully
i  functions: creating Python 3.10 function onimageresize(us-central1)...
✔  functions[onimageresize(us-central1)] Successful create operation.
i  functions: cleaning up build files...

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/python-functions-testing/overview

image

Successfully triggers on events:

image

2023-04-17 15:22:33.801 BST
Received image resize completed event CloudEvent(specversion='1.0', id='630662bf-4650-4d78-9be1-d0462af77004', source='//firebaseextensions.googleapis.com/extensions/projects/python-functions-testing/instances/storage-resize-images', type='firebase.extensions.storage-resize-images.v1.complete', time=datetime.datetime(2023, 4, 17, 14, 22, 29, 946000, tzinfo=datetime.timezone.utc), data={'input': {'bucket': 'python-functions-testing.appspot.com', 'contentDisposition': "inline; filename*=utf-8''cheat-sheet-full.png", 'contentType': 'image/png', 'crc32c': 'VyM+vA==', 'etag': 'CO2yvNuOsf4CEAE=', 'generation': '1681741344348525', 'id': 'python-functions-testing.appspot.com/testing/cheat-sheet-full.png/1681741344348525', 'kind': 'storage#object', 'md5Hash': '16AIolQbCNdxdohwwLHxXw==', 'mediaLink': 'https://storage.googleapis.com/download/storage/v1/b/python-functions-testing.appspot.com/o/testing%2Fcheat-sheet-full.png?generation=1681741344348525&alt=media', 'metadata': {'firebaseStorageDownloadTokens': '8cb4cfc3-efac-4f85-9a83-4e7bb06c8e82'}, 'metageneration': '1', 'name': 'testing/cheat-sheet-full.png', 'selfLink': 'https://www.googleapis.com/storage/v1/b/python-functions-testing.appspot.com/o/testing%2Fcheat-sheet-full.png', 'size': '23241028', 'storageClass': 'STANDARD', 'timeCreated': '2023-04-17T14:22:24.448Z', 'timeStorageClassUpdated': '2023-04-17T14:22:24.448Z', 'updated': '2023-04-17T14:22:24.448Z'}, 'outputs': [{'size': '200x200', 'outputFilePath': 'testing/cheat-sheet-full_200x200.png', 'success': True}]}, subject='testing/cheat-sheet-full.png')

@taeold taeold merged commit 365b9c8 into firebase:main Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants